package com.java;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Arrays;
import java.util.List;

/**
 * 查询id为偶数，年龄大于24，名称大写，并按名称倒叙的第一个姓名
 *
 * @author jingjintao
 * @date 2021/10/27 - 23:31
 **/
public class StreamDemo {
    public static void main(String[] args) {
        User u1 = new User(1, "a", 23);
        User u2 = new User(2, "b", 24);
        User u3 = new User(3, "c", 22);
        User u4 = new User(4, "d", 26);
        User u5 = new User(8, "e", 28);

        List<User> list = Arrays.asList(u1, u2, u3, u4, u5);
        list.stream().filter(u -> {
            return u.getId() % 2 == 0;
        }).filter(u -> u.getAge() > 24).map(u -> u.getName().toUpperCase()).sorted((s1,s2)->s2.compareTo(s1)).limit(1).forEach(System.out::println);
    }
}

@Data
@AllArgsConstructor
@NoArgsConstructor
class User {

    private int id;
    private String name;
    private int age;

}
